package yf.mall.service;


import com.yf.request.SearchParam;
import yf.mall.entity.AddressEntity;
import yf.mall.entity.MallOrderEntity;
import com.yf.service.BaseService;
import yf.mall.vo.ItemVo;
import yf.mall.vo.MallOrderVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 商品订单Service接口
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Aug 13 14:26:20 CST 2019
 */
public interface MallOrderService extends BaseService<MallOrderEntity> {

    /**
     * 从购物车提交订单
     *
     * @param cartIds
     * @param userId
     * @param recordId
     */
    String commitOrder(Long userId,Long vipUserId, AddressEntity address, String remark, Integer payWay, Integer orderType, String noticeUrl, Integer temp, Long recordId,Long[] cardIds,Long teamId,Long shareId);

    /**
     * 待收款收款 有库存扣除库存 没有库存自动进货
     *
     * @param
     */
    void payment(String orderNo,Long userId);

    /**
     * 送出去平级利润
     * 联盟下单当场送出
     * 联盟自动进货当场送出
     * @param userId
     * @param orderNO
     */
    void equalLevel(Long userId,String orderNO);

    /**
     * 送出去负责人利润
     * @param userId
     * @param orderNO
     */
    void vipProfit(Long userId,String orderNO);

    /**
     * 直接提交订单
     *
     * @param skuName
     * @param quantity
     * @param address
     * @param userId
     * @return
     */
//    Long commitOrder(Long userId, Long goodsId, String skuName, Integer quantity, AddressEntity address);



    //分页获取
    List<MallOrderVo> listOrder(Long userId, int page, int limit,Integer orderType,Integer busType);

    List<MallOrderVo> listShareOrder(Long userId, int page, int limit,Integer type);


    List<MallOrderVo> queryListVo(MallOrderVo mallOrderVo,Long userId);

    MallOrderVo getVo(Long id);

//    void downLevelProfit(List<MallOrderEntity> list,HttpServletResponse response);

    void downProfit(MallOrderEntity param,HttpServletResponse response);

    void downAccount(HttpServletResponse response);

    void downStore(HttpServletResponse response);


    void downSale(HttpServletResponse response, String code, Date startDate, Date endDate);

    //微信支付
    void payByWx(String orderNo);

    //管理员支付
    MallOrderEntity adminPay(Long orderId);

    //统一下单
    String unionOrder(MallOrderEntity mallOrderEntity, String noticeUrl);

    //撤销发货订单
    MallOrderEntity deleteOrder(Long userId, Long orderId);
    //提走订单
    MallOrderEntity mentionOrder( Long orderId);

    /**
     * 计算购物车里所有产品的邮费
     *
     * @param items
     * @param province
     * @return
     */
    BigDecimal computeLogFee(List<? extends ItemVo> items, String province);

//    void transfer(Long fromUserId, Long toUser, String remark, Integer type, List<OrderItemEntity> items);


    /**
     * back
     **/


    //下载发货表格
    void downLoad(HttpServletResponse response, HttpServletRequest request);

    void downLoadOrder(HttpServletResponse response,SearchParam<MallOrderVo> params);

    //下载用户已经支付的订单
    void downLoad(HttpServletResponse response, String code, String startDate, String endDate);

    //上传物流订单
    void upload(InputStream file);

    //恢复成新订单
    void renew();


    /**
     * common
     */

    //管理员转货 APP转货 发库存的货
    void transfer(MallOrderVo mallOrderVo);

    MallOrderVo getVo(String orderNo);

    MallOrderEntity findByOrderNo(String orderNo);


    /**
     * Long
     * 确认收货
     *
     * @param userID
     * @param orderNo
     * @return
     */
    MallOrderEntity sureReceipt(Long userID, String orderNo);

    /**
     * Long
     * 根据用户id以及订单状态去查询订单明细
     *
     * @param userId
     * @param status
     * @return
     */
    List<MallOrderVo> findByUserIdAndStatus(Long userId, int status);

    /**
     * 找出还货相关 收款的时候回还货
     * @param orderNo
     * @return
     */
 //   List<MallOrderEntity> findReturn(String orderNo);

    /**
     * 找出自动购买的
     * @param orderNo
     * @return
     */
    MallOrderEntity findAutoBuy(String orderNo);

    /**
     * 生成逆向订单
     * @param orderEntity
     * @return
     */
    MallOrderEntity buildBackOrder(MallOrderEntity orderEntity);

    /**
     * 获取实际支付价格
     * @param orderEntity
     * @return
     */
   BigDecimal getRetailPrice(MallOrderEntity orderEntity);

    void apiUpload(Long userId,Long orderId,String logNo,String logCompany,BigDecimal logFee);

    List<MallOrderVo> findByFromUserId(Long userId, Integer orderStatus, Integer payStatus, int page, int limit);

    Map<String,Object> shopOrderInfo(Long userId);

    void updateOrder(MallOrderEntity mallOrderEntity);

    void autoCancelOrder();

}


